<script>	
	export default {
		onLaunch: function () {
			// #ifdef APP-PLUS
			//升级检测数据
			var appid = plus.runtime.appid;
			var version = plus.runtime.version;
			var imei = plus.device.imei;
			var typeapp = plus.os.name;
			// console.log(imei)
	// 			var info = plus.push.getClientInfo();
	// 			console.log(JSON.stringify( info ))
			// alert( JSON.stringify( info ) );
			//console.log(this.service.FOX_URL)
			var checkUpdate = this.service.FOX_URL+"diamond/checkupdate/" + typeapp; //检查更新地址 
			// console.log(checkUpdate);
			uni.request({
				url: checkUpdate,
				dataType:'json',              
				success: (res) => {
					var foxmsg = res.data;
					// console.log(foxmsg)
					if (foxmsg.code == 200) {
						if(foxmsg.data.uptype == 1 && version < foxmsg.data.version){
						// if(foxmsg.data.uptype == 1){
							let uplock = foxmsg.data.uplock;
							let uptext = '金钻交易平台版本已更新，请跟上升级';
							if(foxmsg.data.uptext){
								uptext = foxmsg.data.uptext;
							}
							if(uplock == 1){
								this.$showModal({ //提醒用户更新
									title: "版本更新",
									content: uptext,
									confirmText:'在线更新',
									showCancel:false,
									success: (res) => {
										if (res.confirm) {
											plus.runtime.openURL(foxmsg.data.downurl);
										}
									}
								})
							}else{
								this.$showModal({ //提醒用户更新
									title: "版本更新",
									content: uptext,
									confirmText:'我要更新',
									cancelText:'暂时不',
									success: (res) => {
										if (res.confirm) {
											plus.runtime.openURL(foxmsg.data.downurl);
										}
									}
								})
							}                            
						}                        
					}
				}
			})
			// 检测升级
			// 锁定屏幕方向
			plus.screen.lockOrientation('portrait-primary'); //锁定
			plus.device.setWakelock(true); //屏幕常亮
			// #endif
		}
	}
</script>

<style>
	/*每个页面公共css */
	@import "./static/css/all.css";
	@import "./static/css/style.css";
</style>
